{extend name="base" /}
{block name="main"}
<style type="text/css">
    .tpt_sels a {
        padding-right: 15px;
        position: relative
    }

    .tpt_sels a {
        padding: 0 20px 0 8px;
        color: #3B6268;
        background: #FFFFBA;
        border: 1px #F8E06E solid;
        margin-right: 5px;
        margin-bottom: 5px;
        font-size: 14px;
        height: 26px;
        line-height: 26px;
        display: block;
        float: left
    }

    .tpt_pres a.selected {
        padding: 0 8px;
        color: #3B6268;
        background: #FFFFBA;
        border: 1px #F8E06E solid;
        margin-right: 5px;
        margin-bottom: 5px;
        font-size: 14px;
        height: 26px;
        line-height: 26px;
        display: block;
        float: left
    }

    .tpt_pres a {
        padding: 0 8px;
        color: #fff;
        background: #5AC7A9;
        border: 1px #5AC7A9 solid;
        margin-right: 5px;
        margin-bottom: 5px;
        font-size: 14px;
        height: 26px;
        line-height: 26px;
        display: block;
        float: left
    }

    .tpt_sels a em {
        width: 12px;
        height: 12px;
        font-style: normal;
        display: block;
        position: absolute;
        top: 7px;
        right: 4px;
        z-index: 2;
        background: url(__ADMIN__/img/sx.png) no-repeat 0 0;
    }

    .cl {
        zoom: 1
    }

    .cl:after {
        content: '\20';
        display: block;
        height: 0;
        clear: both;
        visibility: hidden
    }

</style>
<body>
<div class="fly-panel fly-panel-user">
    <div class="tpt—admin">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>修改内容</legend>
        </fieldset>

        <form class="layui-form">
            <input type="hidden" name="id" value="{$tptc.id}">

            <div class="layui-form-item">
                <label class="layui-form-label">标题</label>
                <div class="layui-input-block">
                    <input type="text" name="title" value="{$tptc.title}" required lay-verify="required"
                           placeholder="必填内容" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item" style="width: 300px;">
                <label class="layui-form-label">所在栏目</label>
                <div class="layui-input-block">
                    <select name="tid">
                        {volist name="tptcs" id="vo"}
                        <option {if condition="$tptc['tid'] eq $vo['id']" }selected="selected" {
                        /if} value="{$vo.id}">{$vo.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">图片</label>
                <a class="layui-btn" id="image" style="float: left;"><i class="layui-icon">&#xe67c;</i>上传图片</a>
                <div class="layui-input-block" style="margin-left: 220px;">
                    <input type="text" name="pic" value="{$tptc.pic}" class="layui-input"
                           style="position: absolute;left: 0;top: 0;">
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">描述</label>
                <div class="layui-input-block">
                    <textarea name="description" autocomplete="off"
                              class="layui-textarea">{$tptc.description}</textarea>
                </div>
            </div>


            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">内容</label>
                <div class="layui-input-block">
                        <script id="container" name="content" type="text/plain" style="height: 500px">{$tptc.content}</script>
                </div>
                <script src = "/public/ueditor/ueditor.config.js"></script>
                <script src="/public/ueditor/ueditor.all.js"></script>

                <script>
                    var serverurl = "{:url('api/upload/ueditor')}";
                    var ue = UE.getEditor('container', {
                        serverUrl: serverurl,
                    });
                </script>
            </div>





                <div class="layui-form-item ">
                    <div class="tpt_item">
                        <input type="hidden" name="keywords" value="{$tptc.keywords}">
                        <div id="tpt_sel" class="tpt_sels tpt-none-750" style="margin-top: 20px;">
                        <span style="margin: 0 0 5px 110px;float: left;">
                        {if condition="$tptc['keywords'] neq ''"}<?php $arr=explode(',', $tptc['keywords']);foreach ($arr as $k=>
                            $v){echo "<a href='javascript:;'>$v<em></em></a>";}?>{/if}
                        </span>
                            <div class="layui-form-item" style="margin-bottom: 10px;">
                                <label class="layui-form-label">标签</label>
                                <div class="layui-input-block">
                                    <input id="tpt_input" type="text" value="" autocomplete="off" class="layui-input"
                                           style="width: 400px;float: left;margin-right: 20px;">
                                    <button class="layui-btn" id="tpt_btn" type="button"
                                            style="background: #FF5722;margin-bottom: 10px;">添加标签</button>
                                </div>
                            </div>
                        </div>
                        <div id="tpt_pre" class="tpt_pres cl tpt-none-750" style="margin: 0 0 15px 110px;">
                            {volist name="tagss" id="tag"}
                            {if condition="$tag neq ''"}<a href="javascript:;">{$tag}</a>{/if}
                            {/volist}
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="content_edit">立即提交</button>
                        <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                    </div>
                </div>

        </form>
    </div>
</div>
<script type="text/javascript" src="/public/js/keywords.js"></script>

<script>
    layui.use(['form', 'upload'], function () {
        var form = layui.form,
            upload = layui.upload,
            jq = layui.jquery;

        upload.render({
            url: '{:url("api/upload/upfile")}'
            , elem: '#image'
            , before: function (input) {
                loading = layer.load(2, {
                    shade: [0.2, '#000']
                });
            }
            , done: function (res) {
                layer.close(loading);
                jq('input[name=pic]').val(res.path);
                layer.msg(res.msg, {icon: 1, time: 1000});
            }
        });

        form.on('submit(content_edit)', function (data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            var param = data.field;
            jq.post('{:url("content/edit")}', param, function (data) {
                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                        location.href = '{:url("content/index")}';
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
                }
            });
            return false;
        });

    })
</script>

{/block}